<template>
    <pageBox>
        <view class="stock clearfix">

            <view class="stock " style="overflow:hidden">
                <view  v-if="isPermission('stock_add')" style="float:left; width:375rpx; text-align: center;">
                    <navigator class="img-box" url="enter/enter">
                        <image src="../../static/images/icon/icon_kiln_entry_registration@2x.png" style="margin: 0 auto; margin-top:50rpx"></image>
                        <text>进窑登记</text>
                    </navigator>
                </view>

                <view class="item" v-if="isPermission('stock_list')" style=" float:left; width:375rpx; text-align: center;margin-top:50rpx">
                    <navigator class="img-box" url="record/record">
                        <image src="../../static/images/icon/icon_registration_record@2x.png" style="margin: 0 auto;" ></image>
                        <text>登记记录</text>
                    </navigator>
                </view>

                <view v-if="isPermission2('待检统计(已检统计)')"  style="float:left;width:375rpx; text-align: center;margin-top:60rpx">
                    <navigator class="img-box" url="statistics/statistics">
                        <image src="../../static/images/icon/icon_tatistics@2x.png" style="margin: 0 auto;"></image>
                        <text>待检统计</text>
                    </navigator>
                </view>

                <view class="item">
                    <view  v-if="isPermission2('待检统计(已检统计)')" style=" float:left;width:375rpx; text-align: center;margin-top:60rpx">
                        <navigator class="img-box" url="recordYet/recordYet">
                            <image src="../../static/images/icon/icon_checked_records@2x.png" style="margin: 0 auto;"></image>
                            <text>已检记录</text>
                        </navigator>
                    </view>
                </view>
            </view>

        </view>
    </pageBox>
</template>

<script>
export default {
    data() {
        return {
            stockPermission: []
        };
    },
    methods: {
        isPermission(name) {
            let data = uni.getStorageSync("stockPermission") // 缓存起来的数组
            if (data.length) {
                return data.includes(name)
            }
            return false
        },
        isPermission2(name) {
            let data = uni.getStorageSync("stockPermission2") // 缓存起来的数组
            if (data.length) {
                return data.includes(name)
            }
            return false
        }
        // getMsg(){
        //     this.stockPermission.forEach(item => {
        //         return stock_add
        //     });
        // }
    },
    onShow() {
        this.stockPermission = uni.getStorageSync("stockPermission")
        console.log(this.stockPermission)
        console.log(this.isPermission("stock_add"))
        if (this.stockPermission.length === 0) {
            uni.showModal({
                title: '您暂时此权限,请联系管理员开启',
                showCancel: false,
                success: function (res) {
                    if (res.confirm) {
                        console.log('用户点击确定');
                    } else if (res.cancel) {
                        console.log('用户点击取消');
                    }
                }
            });
        }

        // this.getMsg()
    }
};
</script>

<style lang="scss">
page {}

.clearfix::after {
    content: '.';
    /* ::after必须配合content一起使用才有效果;*/
    display: block;
    /*因为伪元素是个行内元素，而清除浮动必须用块级元素*/
    clear: both;
    /*清除浮动的代码*/
    visibility: hidden;
    /*  隐藏content中的内容部分*/
    height: 0;
    /* 将content中的内容撑开的高度去掉*/
    line-height: 0;
    /* 为了更好的浏览器兼容*/
}

.clearfix {
 
}

.stock {
    width: 750rpx;
    .flex-box {
        // width: 750rpx;
        // margin: 70rpx auto;

        // &:nth-child(2) {
        //     // margin-top: 130rpx;
        // }
    }

    // .item {
    //     align-content: center;
    // }

    .img-box {
   
        // width: 176rpx;
        // text-align: center;
    }

    text {
        font-size: $fs-base-x;
        display: inline-block;
        margin-top: 20rpx;
    }

    image {
        width: 200rpx;
        height: 200rpx;
        display: block;
    }
}
</style>
